<?php

	$content_xml .= '
	<office:body>
		<office:text>
			<text:sequence-decls>
				<text:sequence-decl text:display-outline-level="0"
					text:name="Illustration" />
				<text:sequence-decl text:display-outline-level="0"
					text:name="Table" />
				<text:sequence-decl text:display-outline-level="0"
					text:name="Text" />
				<text:sequence-decl text:display-outline-level="0"
					text:name="Drawing" />
			</text:sequence-decls>
			<text:p text:style-name="P4">' . htmlspecialchars($firma->nume) . '</text:p>
			<text:p text:style-name="P3" />
			<text:p text:style-name="P1" />
			<table:table table:name="Table3"
				table:style-name="Table3">
				<table:table-column table:style-name="Table3.A"
					table:number-columns-repeated="4" />
				<table:table-row>
					<table:table-cell table:style-name="Table3.A1"
						table:number-columns-spanned="2" office:value-type="string">
						<text:p text:style-name="P6">' . LANG_Date_firma . '</text:p>
					</table:table-cell>
					<table:covered-table-cell />
					<table:table-cell table:style-name="Table3.C1"
						table:number-columns-spanned="2" office:value-type="string">
						<text:p text:style-name="P6">' . LANG_ADRESA . '</text:p>
					</table:table-cell>
					<table:covered-table-cell />
				</table:table-row>
				<table:table-row>
					<table:table-cell table:style-name="Table3.A2"
						office:value-type="string">
						<text:p text:style-name="P7">' . LANG_cod_fiscal . '</text:p>
					</table:table-cell>
					<table:table-cell table:style-name="Table3.A2"
						office:value-type="string">
						<text:p text:style-name="P5">' . htmlspecialchars($firma->cf) . '</text:p>
					</table:table-cell>
					<table:table-cell table:style-name="Table3.A2"
						office:value-type="string">
						<text:p text:style-name="P7">' . LANG_ADRESA . '</text:p>
					</table:table-cell>
					<table:table-cell table:style-name="Table3.D2"
						office:value-type="string">
						<text:p text:style-name="P5">' . htmlspecialchars($firma->adresa->adresa) . '</text:p>
					</table:table-cell>
				</table:table-row>
				<table:table-row>
					<table:table-cell table:style-name="Table3.A2"
						office:value-type="string">
						<text:p text:style-name="P7">
							' . LANG_RC . '
						</text:p>
					</table:table-cell>
					<table:table-cell table:style-name="Table3.A2"
						office:value-type="string">
						<text:p text:style-name="P5">' . htmlspecialchars($firma->rc) . '</text:p>
					</table:table-cell>
					<table:table-cell table:style-name="Table3.A2"
						office:value-type="string">
						<text:p text:style-name="P7">' . LANG_ORAS . '</text:p>
					</table:table-cell>
					<table:table-cell table:style-name="Table3.D2"
						office:value-type="string">
						<text:p text:style-name="P5">' . htmlspecialchars($firma->adresa->oras) . '</text:p>
					</table:table-cell>
				</table:table-row>
				<table:table-row>
					<table:table-cell table:style-name="Table3.A2"
						office:value-type="string">
						<text:p text:style-name="P7">
							' . LANG_TEL_FIX . '
						</text:p>
					</table:table-cell>
					<table:table-cell table:style-name="Table3.A2"
						office:value-type="string">
						<text:p text:style-name="P5">' . htmlspecialchars($firma->tel_fix) . '</text:p>
					</table:table-cell>
					<table:table-cell table:style-name="Table3.A2"
						office:value-type="string">
						<text:p text:style-name="P7">' . LANG_JUDET . '</text:p>
					</table:table-cell>
					<table:table-cell table:style-name="Table3.D2"
						office:value-type="string">
						<text:p text:style-name="P5">' . htmlspecialchars($firma->adresa->judet) . '</text:p>
					</table:table-cell>
				</table:table-row>
				<table:table-row>
					<table:table-cell table:style-name="Table3.A2"
						office:value-type="string">
						<text:p text:style-name="P7">
							' . LANG_TEL_FAX . '
						</text:p>
					</table:table-cell>
					<table:table-cell table:style-name="Table3.A2"
						office:value-type="string">
						<text:p text:style-name="P5">' . htmlspecialchars($firma->tel_fax) . '</text:p>
					</table:table-cell>
					<table:table-cell table:style-name="Table3.A2"
						office:value-type="string">
						<text:p text:style-name="P7">' . LANG_COD_POSTAL . '</text:p>
					</table:table-cell>
					<table:table-cell table:style-name="Table3.D2"
						office:value-type="string">
						<text:p text:style-name="P5">' . htmlspecialchars($firma->adresa->cod_postal) . '</text:p>
					</table:table-cell>
				</table:table-row>
				<table:table-row>
					<table:table-cell table:style-name="Table3.A2"
						office:value-type="string">
						<text:p text:style-name="P7">
							' . LANG_TEL_MOBIL . '
						</text:p>
					</table:table-cell>
					<table:table-cell table:style-name="Table3.A2"
						office:value-type="string">
						<text:p text:style-name="P5">' . htmlspecialchars($firma->tel_mobil) . '</text:p>
					</table:table-cell>
					<table:table-cell table:style-name="Table3.A2"
						office:value-type="string">
						<text:p text:style-name="P7">' . LANG_TARA . '</text:p>
					</table:table-cell>
					<table:table-cell table:style-name="Table3.D2"
						office:value-type="string">
						<text:p text:style-name="P5">' . htmlspecialchars($firma->adresa->tara) . '</text:p>
					</table:table-cell>
				</table:table-row>
				<table:table-row>
					<table:table-cell table:style-name="Table3.A2"
						office:value-type="string">
						<text:p text:style-name="P7">' . LANG_EMAIL . '</text:p>
					</table:table-cell>
					<table:table-cell table:style-name="Table3.A2"
						office:value-type="string">
						<text:p text:style-name="P5">' . htmlspecialchars($firma->email) . '</text:p>
					</table:table-cell>
					<table:table-cell table:style-name="Table3.C7"
						table:number-rows-spanned="5" table:number-columns-spanned="2"
						office:value-type="string">
						<text:p text:style-name="P5" />
					</table:table-cell>
					<table:covered-table-cell />
				</table:table-row>
				<table:table-row>
					<table:table-cell table:style-name="Table3.A2"
						office:value-type="string">
						<text:p text:style-name="P7">' . LANG_WEB . '</text:p>
					</table:table-cell>
					<table:table-cell table:style-name="Table3.A2"
						office:value-type="string">
						<text:p text:style-name="P5">' . htmlspecialchars($firma->web) . '</text:p>
					</table:table-cell>
					<table:covered-table-cell />
					<table:covered-table-cell />
				</table:table-row>
				<table:table-row>
					<table:table-cell table:style-name="Table3.A2"
						office:value-type="string">
						<text:p text:style-name="P7">' . LANG_TIP_FIRMA . '</text:p>
					</table:table-cell>
					<table:table-cell table:style-name="Table3.A2"
						office:value-type="string">
						<text:p text:style-name="P5">';
				if ($firma->tip == CT_TIP_FIRMA_ALL)
					$content_xml .= LANG_FIRMA_TRANSPORTATOR . ", " . LANG_FIRMA_SPEDITII . ", " . LANG_FIRMA_FABRICA; 
				if ($firma->tip == CT_TIP_FIRMA_TRANSPORTATOR) 
					$content_xml .= LANG_FIRMA_TRANSPORTATOR; 
				if ($firma->tip == CT_TIP_FIRMA_SPEDITII) 
					$content_xml .= LANG_FIRMA_SPEDITII; 
				if ($firma->tip == CT_TIP_FIRMA_FABRICA)
					$content_xml .= LANG_FIRMA_FABRICA;             
				
				$content_xml .= '
						</text:p>
					</table:table-cell>
					<table:covered-table-cell />
					<table:covered-table-cell />
				</table:table-row>
				<table:table-row>
					<table:table-cell table:style-name="Table3.A2" office:value-type="string">
						<text:p text:style-name="P7">' . LANG_Calitate_firma . '</text:p>
					</table:table-cell>
					<table:table-cell table:style-name="Table3.A2"
						office:value-type="string">
						<text:p text:style-name="P5">';
							if ($firma->calitate_firma == CT_FIRMA_SERIOASA) 
								$content_xml .= LANG_Firma_serioasa; 
							if ($firma->calitate_firma == CT_FIRMA_NESERIOASA) 
								$content_xml .= LANG_Firma_neserioasa;	
							$content_xml .= '
						</text:p>
					</table:table-cell>
					<table:covered-table-cell />
					<table:covered-table-cell />
				</table:table-row>
				<table:table-row>
					<table:table-cell table:style-name="Table3.A2" office:value-type="string">
						<text:p text:style-name="P7">' . LANG_Comentariu . '</text:p>
					</table:table-cell>
					<table:table-cell table:style-name="Table3.A2"
						office:value-type="string">
						<text:p text:style-name="P5">' . htmlspecialchars($firma->comentariu) . '</text:p>
					</table:table-cell>
					<table:covered-table-cell />
					<table:covered-table-cell />
				</table:table-row>				
			</table:table>
			<text:p text:style-name="P2" />
			<text:p text:style-name="P2" />';
	
	/*
	 * urmeaza acuma sa fac un for printre conturile firmei
	 */
	
	$exista = false;
    for ($i = 0; $i < count($firma->conturi); $i++) {
        if ($firma->conturi[$i]->status != CT_CONT_DELETED) {
            $exista = true;
            break;
        }
    }	
    if ($exista) {    	    
		$content_xml .= '
			<table:table table:name="Table1"
				table:style-name="Table1">
				<table:table-column table:style-name="Table1.A"
					table:number-columns-repeated="3" />
				<table:table-row table:style-name="Table1.1">
					<table:table-cell table:style-name="Table1.A1"
						table:number-columns-spanned="3" office:value-type="string">
						<text:p text:style-name="P6">' . LANG_Conturi . '</text:p>
					</table:table-cell>
					<table:covered-table-cell />
					<table:covered-table-cell />
				</table:table-row>
				<table:table-row table:style-name="Table1.1">
					<table:table-cell table:style-name="Table1.A2"
						office:value-type="string">
						<text:p text:style-name="P8">' . LANG_CONT . '</text:p>
					</table:table-cell>
					<table:table-cell table:style-name="Table1.A2"
						office:value-type="string">
						<text:p text:style-name="P8">' . LANG_BANCA . '</text:p>
					</table:table-cell>
					<table:table-cell table:style-name="Table1.C2"
						office:value-type="string">
						<text:p text:style-name="P8">' . LANG_SUCURSALA . '</text:p>
					</table:table-cell>
				</table:table-row>';
		for ($i = 0; $i < count($firma->conturi); $i++) {
			if ($firma->conturi[$i]->status != CT_CONT_DELETED) {
				$content_xml .= '		
				<table:table-row table:style-name="Table1.1">
					<table:table-cell table:style-name="Table1.A2"
						office:value-type="string">
						<text:p text:style-name="P9">
							' . htmlspecialchars($firma->conturi[$i]->cont) . ' ' . $currencies[$firma->conturi[$i]->moneda] . '
						</text:p>
					</table:table-cell>
					<table:table-cell table:style-name="Table1.A2"
						office:value-type="string">
						<text:p text:style-name="P9">' . htmlspecialchars($firma->conturi[$i]->banca) . '</text:p>
					</table:table-cell>
					<table:table-cell table:style-name="Table1.C2"
						office:value-type="string">
						<text:p text:style-name="P9">' . htmlspecialchars($firma->conturi[$i]->sucursala) . '</text:p>
					</table:table-cell>
				</table:table-row>';	
			}
		}
		$content_xml .= '		
			</table:table>';			
    }
    
    /*
     * urmeaza acuma sa fac un for printre contactele acestei firme
     */
    
	$exista = false;
    for ($i = 0; $i < count($firma->contacte); $i++) {
        if ($firma->contacte[$i]->status != CT_CONTACT_DELETED) {
            $exista = true;
            break;
        }
    }

    if ($exista) {    
		$content_xml .= '
			<text:p text:style-name="P2" />
			<text:p text:style-name="P2" />
			<table:table table:name="Table2"
				table:style-name="Table2">
				<table:table-column table:style-name="Table2.A" />
				<table:table-column table:style-name="Table2.B" />
				<table:table-column table:style-name="Table2.C" />
				<table:table-column table:style-name="Table2.A" />
				<table:table-column table:style-name="Table2.E"
					table:number-columns-repeated="3" />
				<table:table-row>
					<table:table-cell table:style-name="Table2.A1"
						table:number-columns-spanned="7" office:value-type="string">
						<text:p text:style-name="P6">' . LANG_Contacte . '</text:p>
					</table:table-cell>
					<table:covered-table-cell />
					<table:covered-table-cell />
					<table:covered-table-cell />
					<table:covered-table-cell />
					<table:covered-table-cell />
					<table:covered-table-cell />
				</table:table-row>
				<table:table-row>
					<table:table-cell table:style-name="Table2.A2"
						office:value-type="string">
						<text:p text:style-name="P8">' . LANG_NUME . '</text:p>
					</table:table-cell>
					<table:table-cell table:style-name="Table2.A2"
						office:value-type="string">
						<text:p text:style-name="P8">' . LANG_SEX_CONTACT . '</text:p>
					</table:table-cell>
					<table:table-cell table:style-name="Table2.A2"
						office:value-type="string">
						<text:p text:style-name="P8">' . LANG_FUNCTIE_CONTACT . '</text:p>
					</table:table-cell>
					<table:table-cell table:style-name="Table2.A2"
						office:value-type="string">
						<text:p text:style-name="P8">' . LANG_TEL_FIX . '</text:p>
					</table:table-cell>
					<table:table-cell table:style-name="Table2.A2"
						office:value-type="string">
						<text:p text:style-name="P8">' . LANG_TEL_FAX . '</text:p>
					</table:table-cell>
					<table:table-cell table:style-name="Table2.A2"
						office:value-type="string">
						<text:p text:style-name="P8">' . LANG_TEL_MOBIL . '</text:p>
					</table:table-cell>
					<table:table-cell table:style-name="Table2.G2"
						office:value-type="string">
						<text:p text:style-name="P8">' . LANG_EMAIL . '</text:p>
					</table:table-cell>
				</table:table-row>';    	
		for ($i = 0; $i < count($firma->contacte); $i++) {
			if ($firma->contacte[$i]->status != CT_CONTACT_DELETED) {        	
				$content_xml .= '
					<table:table-row>
						<table:table-cell table:style-name="Table2.A2"
							office:value-type="string">
							<text:p text:style-name="P9">
								' . htmlspecialchars($firma->contacte[$i]->nume) . '									
							</text:p>
						</table:table-cell>
						<table:table-cell table:style-name="Table2.A2"
							office:value-type="string">
							<text:p text:style-name="P9">';
			
							if ($firma->contacte[$i]->sex == CT_SEX_MASCULIN)
								$content_xml .= LANG_SEX_MALE;
							else
								$content_xml .= LANG_SEX_FEMALE;
								
							$content_xml .= '
							</text:p>
						</table:table-cell>
						<table:table-cell table:style-name="Table2.A2"
							office:value-type="string">
							<text:p text:style-name="P9">' . htmlspecialchars($firma->contacte[$i]->functie) . '</text:p>
						</table:table-cell>
						<table:table-cell table:style-name="Table2.A2"
							office:value-type="string">
							<text:p text:style-name="P9">' . htmlspecialchars($firma->contacte[$i]->tel_fix) . '</text:p>
						</table:table-cell>
						<table:table-cell table:style-name="Table2.A2"
							office:value-type="string">
							<text:p text:style-name="P9">' . htmlspecialchars($firma->contacte[$i]->tel_fax) . '</text:p>
						</table:table-cell>
						<table:table-cell table:style-name="Table2.A2"
							office:value-type="string">
							<text:p text:style-name="P9">' . htmlspecialchars($firma->contacte[$i]->tel_mobil) . '</text:p>
						</table:table-cell>
						<table:table-cell table:style-name="Table2.G2"
							office:value-type="string">
							<text:p text:style-name="P9">' . htmlspecialchars($firma->contacte[$i]->email) . '</text:p>
						</table:table-cell>
					</table:table-row>';
			}
		}
		$content_xml .= '	
				</table:table>';	
		
    }
    
    
    	/*
	 * urmeaza acuma sa fac un for printre rutele firmei
	 */
	
	$exista = false;
    for ($i = 0; $i < count($firma->rute); $i++) {
        if ($firma->rute[$i]->status != CT_RUTA_FIRMA_DELETED) {
            $exista = true;
            break;
        }
    }	
    if ($exista) {    	    
		$content_xml .= '
			<text:p text:style-name="P2" />
			<text:p text:style-name="P2" />		
			<table:table table:name="Table4"
				table:style-name="Table4">
				<table:table-column table:style-name="Table4.A"
					table:number-columns-repeated="2" />
				<table:table-row table:style-name="Table4.1">
					<table:table-cell table:style-name="Table4.A1"
						table:number-columns-spanned="2" office:value-type="string">
						<text:p text:style-name="P6">' . LANG_Rute . '</text:p>
					</table:table-cell>
					<table:covered-table-cell />
				</table:table-row>
				<table:table-row table:style-name="Table4.1">
					<table:table-cell table:style-name="Table4.A2"
						office:value-type="string">
						<text:p text:style-name="P8">' . LANG_Loc1 . '</text:p>
					</table:table-cell>
					<table:table-cell table:style-name="Table4.B2"
						office:value-type="string">
						<text:p text:style-name="P8">' . LANG_Loc2 . '</text:p>
					</table:table-cell>
				</table:table-row>';
		for ($i = 0; $i < count($firma->rute); $i++) {
			if ($firma->rute[$i]->status != CT_RUTA_FIRMA_DELETED) {
				$content_xml .= '		
				<table:table-row table:style-name="Table4.1">
					<table:table-cell table:style-name="Table4.A2"
						office:value-type="string">
						<text:p text:style-name="P9">' . $firma->rute[$i]->loc1 . '</text:p>
					</table:table-cell>
					<table:table-cell table:style-name="Table4.B2"
						office:value-type="string">
						<text:p text:style-name="P9">' . $firma->rute[$i]->loc2 . '</text:p>
					</table:table-cell>
				</table:table-row>';	
			}
		}
		$content_xml .= '		
			</table:table>';			
    }    
	$content_xml .= '		
			<text:p text:style-name="P2" />
		</office:text>
	</office:body>
</office:document-content>';
?>			